package org.spring.boot.rabbitmq.conf;

import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author: eastcom
 * @desc: Rabbist路由信息配置类
 **/
@Component
public class RabbitExchangeConfig {

	@Value("${rabbitmq.exchange.cache.direct}")
	private String cacheDirect;

	@Value("${rabbitmq.exchange.cache.fanout}")
	private String cacheFanout;

	@Value("${rabbitmq.exchange.cache.topic}")
	private String cacheTopic;


	@Bean(name = "directCacheExchange")
	public DirectExchange directExchange(){
		DirectExchange directExchange = new DirectExchange(cacheDirect);
		return directExchange;
	}

	@Bean(name = "fanoutCacheExchange")
	public FanoutExchange fanoutExchange(){
		FanoutExchange fanoutExchange = new FanoutExchange(cacheFanout);
		return fanoutExchange;
	}

	@Bean(name = "topicCacheExchange")
	public TopicExchange topicExchange(){
		TopicExchange topicExchange = new TopicExchange(cacheTopic);
		return topicExchange;
	}

	public String getCacheDirect() {
		return cacheDirect;
	}

	public String getCacheFanout() {
		return cacheFanout;
	}

	public String getCacheTopic() {
		return cacheTopic;
	}
}
